using OneCaps.Core.Interfaces;
using OneCaps.Core.Models;

namespace OneCaps.Infrastructure.Hardware
{
    /// <summary>
    /// 车牌识别服务模拟实现
    /// </summary>
    public class MockLicensePlateRecognitionService : ILicensePlateRecognitionService
    {
        public Task<LicensePlateRecognitionResult> RecognizeAsync(byte[] imageData)
        {
            // 模拟识别，返回固定车牌
            return Task.FromResult(new LicensePlateRecognitionResult
            {
                IsSuccess = true,
                LicensePlate = "京A12345",
                Confidence = 0.98,
                ProcessingTimeMs = 50,
                PlateType = LicensePlateType.Normal,
                PlateColor = "蓝色"
            });
        }

        public Task<LicensePlateRecognitionResult> RecognizeFromFileAsync(string imagePath)
        {
            // 模拟识别，返回固定车牌
            return RecognizeAsync(Array.Empty<byte>());
        }

        public Task<IEnumerable<LicensePlateRecognitionResult>> RecognizeBatchAsync(IEnumerable<byte[]> imageDataList)
        {
            var results = imageDataList.Select(_ => new LicensePlateRecognitionResult
            {
                IsSuccess = true,
                LicensePlate = "京A12345",
                Confidence = 0.98,
                ProcessingTimeMs = 50,
                PlateType = LicensePlateType.Normal,
                PlateColor = "蓝色"
            });
            return Task.FromResult(results);
        }

        public bool ValidateLicensePlate(string licensePlate)
        {
            try { var lp = new LicensePlate(licensePlate); return true; } catch { return false; }
        }

        public Task<RecognitionServiceStatus> GetServiceStatusAsync()
        {
            return Task.FromResult(new RecognitionServiceStatus
            {
                IsAvailable = true,
                Version = "Mock 1.0",
                ModelVersion = "MockModel",
                AverageProcessingTimeMs = 50,
                SuccessRate = 1.0,
                LastUpdateTime = DateTime.Now
            });
        }
    }
} 